<template>
  <div class="time-select">
    {{ info.label }}
    <el-date-picker
      v-model="info.field_value"
      align="right"
      type="datetime"
      placeholder=""
      value-format="yyyy-MM-dd HH:mm"
      format="yyyy-MM-dd HH:mm"
      size="medium" 
      :readonly="pdf==1"
      :picker-options="pickerOptions">
    </el-date-picker>
  </div>
</template>

<script>
import { timeFormatter } from "UTILS/format";

export default {
  name: "DateTime",
  props: {
    info:{
    },
    pdf:{

    }
  },
  watch: {
    // info: {
    //   handler(val) {
    //     this.time = val;
    //   },
    //   deep: true, // 使用 deep 选项进行深度监视
    //   immediate: true,
    // },
  },
  data() {
    return {
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        shortcuts: [{
          text: '今天',
          onClick(picker) {
            picker.$emit('pick', new Date());
          }
        }, {
          text: '昨天',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24);
            picker.$emit('pick', date);
          }
        }, {
          text: '一周前',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', date);
          }
        }]
      },
    
    };
  },
  created() {
  
  },
  destroyed() {},
  methods: {
    destroyed() {
    },
  },
};
</script>

<style  lang="less">
.time-select{
  
.el-input__prefix{
    display: none;
}
.el-input .el-input__inner{
    border: none;
}
}
</style>

